// 1. 导入mongoose
const mongo = require('mongoose');
// 2. 连接数据库
mongo.connect('mongodb://localhost:27017/XA0315')
// 3. 创建连接回调 connection.on("open",callback)
mongo.connection.on('open',()=>{
    console.log("数据库连接成功");
})
    // 5. 创建文档解构 new mongoose.Schema()
    // 6. 创建模型对象 mongoose.model()
    // 7. 批量插入 model.insertMany({},callback)
mongo.connection.on('error',()=>{
    console.log("数据库连接失败");
})

module.exports = mongo;

console.log('connent');